<?php

namespace Classes;

use Classes\db\DBConnection;
use Classes\Relation;
use PDO;
use Exception;

class User {
	public static function searchUser($username) {
		$connection = DBConnection::getDBConnection ();
		
		$username = "%" . $username . "%";
		
		$statement = "SELECT *
						FROM `user`
						WHERE user_name like :USERNAME";
		$stmt = $connection->prepare ( $statement );
		$stmt->bindValue ( ":USERNAME", $username, \PDO::PARAM_STR );
		$stmt->execute ();
		$result = $stmt->fetchAll ();
		return $result;
	}
	
	public static function getUser($user_id) {
		$connection = DBConnection::getDBConnection ();
		
		$statement = "SELECT *
						FROM `user`
						WHERE user_id=:USER_ID";
		$stmt = $connection->prepare ( $statement );
		$stmt->bindValue ( ":USER_ID", $user_id, \PDO::PARAM_INT );
		$stmt->execute ();
		$result = $stmt->fetchAll ();
		return $result[0];
	}
}